package org.webcamp.results.web;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.webcamp.results.dto.QuestionaryResult;
import org.webcamp.results.services.ResultsService;
import org.webcamp.users.dto.User;

@Controller
public class ResultsController {

	private ResultsService resultsService;

	public void setResultsService(ResultsService resultsService) {
		this.resultsService = resultsService;
	}

	@RequestMapping("user-results")
	public ModelAndView viewResults(HttpSession session) {
		User user = (User) session.getAttribute("user");
		List<QuestionaryResult> results = resultsService.getUserResult(user.getId());
		return new ModelAndView("user_overall_results", "results", results);
	}
}
